import 'package:flutter/material.dart';
import 'package:aweb5/base/BaseWidget.dart';
//import 'package:city_pickers/city_pickers.dart';
//import 'package:flutter_picker/flutter_picker.dart';
//import 'package:convert/convert.dart';
import 'dart:convert';
import 'package:aweb5/config/Data.dart';
//import 'package:city_picker/city_picker.dart';
//import 'package:address_picker/address_picker.dart';

class AddLocation extends BaseWidget {
  @override
  State<AddLocation> createState() => AddLocationState();
}

class AddLocationState extends BaseWidgetState<AddLocation> {
  @override
  void initState() {
    super.initState();
//    initPicker();
  }



  @override
  Widget build(BuildContext context) {
    init(context);

    return Scaffold(
      backgroundColor: Colors.white,
      appBar: appBarWithBack("新增地址"),
      body: Column(
        children: <Widget>[
          Divider(
            color: Color(0xfff7f7f7),
          ),
          Expanded(child: list())
        ],
      ),
    );
  }

  Widget list() {
    return ListView(
      children: <Widget>[
        Container(
//
          color: Colors.white,
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.only(left: 10, right: 10),
          child: Row(
            children: <Widget>[
              Container(
                width: 68,
                child: Text(
                  "收货人",
                  style: TextStyle(fontSize: 13),
                ),
              ),
              Expanded(
                  child: Container(
                alignment: Alignment.bottomLeft,
                padding: EdgeInsets.only(top: 0),
                child: TextField(
                  decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: "请输入收货人姓名",
                    hintStyle: TextStyle(
                      color: Color(0xffb5b5b5),
                      fontSize: 12,
                    ),
                  ),
                ),
              ))
            ],
          ),
        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        ),
        Container(
          color: Colors.white,
          padding: EdgeInsets.only(left: 10, right: 10),
          child: Row(
            children: <Widget>[
              Container(
                width: 68,
                child: Text(
                  "联系方式",
                  style: TextStyle(fontSize: 13),
                ),
              ),
              Expanded(
                  child: Container(
                alignment: Alignment.bottomLeft,
                padding: EdgeInsets.only(top: 0),
                child: TextField(
                  decoration: InputDecoration(
                      border: InputBorder.none,
                      hintText: "请输入联系方式",
                      hintStyle:
                          TextStyle(color: Color(0xffb5b5b5), fontSize: 12)),
                ),
              ))
            ],
          ),
        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        ),
        InkWell(
          child: Container(
            padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Container(
                  width: 68,
                  child: Text(
                    "所在地区",
                    style: TextStyle(fontSize: 13),
                  ),
                ),
                Image.asset(
                  "assets/rightarrow.png",
                  width: 9,
                  height: 18,
                )
              ],
            ),
          ),
          onTap: () {
//         showPickerModal(context);
            showModalBottomSheet(
                context: context,
                builder: (context) => BottomSheet(
                    onClosing: () {},
                    builder: (context) =>
                        Column(children: <Widget>[
//                          Container(
//                            height: 250.0,
//                            child: AddressPicker(
//                              style: TextStyle(color: Colors.black, fontSize: 17),
//                              mode: AddressPickerMode.provinceCityAndDistrict,
//                              onSelectedAddressChanged: (address) {
//                                print('${address.currentProvince.province}');
//                                print('${address.currentCity.city}');
//                                print('${address.currentDistrict.area}');
//                              },
//                            ),
//                          ),
                          Container(height: 49,
                          child: Row(children: <Widget>[
                            Expanded(child:
                            InkWell(child:  Container(
                              alignment: Alignment.center,
                              child: Text("取消",style: TextStyle(color: Color(0xff888888),fontSize: 15),),

                            )),
                           ),
                            Expanded(child:
                            InkWell(child:  Container(
                              alignment: Alignment.center,
                              child: Text("确定",style: TextStyle(color: Color(0xff000000),fontSize: 15),),

                            )),
                            )
                          ],),
                          )
                          
                        ],)
                        ));
          },
        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        ),
        Container(
          color: Colors.white,
          padding: EdgeInsets.only(left: 10, right: 10),
          child: Row(
            children: <Widget>[
              Container(
                width: 68,
                child: Text(
                  "联系方式",
                  style: TextStyle(fontSize: 13),
                ),
              ),
              Expanded(
                  child: Container(
                padding: EdgeInsets.only(top: 0),
                child: TextField(
                  decoration: InputDecoration(
                      border: InputBorder.none,
                      hintText: "请输入联系方式",
                      hintStyle:
                          TextStyle(color: Color(0xffb5b5b5), fontSize: 12)),
                ),
              ))
            ],
          ),
        ),
      ],
    );
  }

//  Result resultArr = new Result();

//  void _clickEventFunc() async {
////    Result tempResult = await CityPickers.showCityPicker(
////        context: context,
////        theme: Theme.of(context).copyWith(primaryColor: Color(0xfffe1314)), // 设置主题
////        locationCode: resultArr != null ? resultArr.areaId ?? resultArr.cityId ?? resultArr.provinceId : null, // 初始化地址信息
////        cancelWidget: Text(
////          '取消',
////          style: TextStyle(fontSize: 26,color: Color(0xff999999)),
////        ),
////        confirmWidget: Text(
////          '确定',
////          style: TextStyle(fontSize: 26,color: Color(0xfffe1314)),
////        ),
////        height: 220.0
////    );
////    if(tempResult != null){
////      setState(() {
////        resultArr = tempResult;
////      });
////    }
//    CityResult result = await showCityPicker(context);
//    String province = result?.province; // 省
//    String city = result?.city; // 市
//    String county = result?.county;
//    print(province);
//  }

//  showPickerModal(BuildContext context) {
//    new Picker(
//        adapter: PickerDataAdapter<String>(
//            pickerdata: new JsonDecoder().convert(Data.city1)),
//        changeToFirst: true,
//        hideHeader: false,
//        onConfirm: (Picker picker, List value) {
//          print(value.toString());
//          print(picker.adapter.text);
//        }).showModal(this.context); //_scaffoldKey.currentState);
//  }

//  void initPicker() async {
//    CityResult result = await showCityPicker(context,
//        initCity: CityResult()
//          ..province = "" // 省
//          ..city = "" // 市
//          ..county = "");
//  }
}
